home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-9.10-netbook-remix-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / sysv-rc.prerm < prev    next >
Text File  |  2009-10-19  |  2KB  |  98 lines

  1. #! /bin/sh
  2. #
  3. # sysv-rc prerm
  4. #
  5.  
  6. set -e
  7.  
  8. revert_to_legacy_ordering() {
  9.     # First, check that we have all the needed actions recorded
  10.     present=""
  11.     missing=""
  12.     for script in /etc/init.d/* ; do
  13.     name=$(basename $script)
  14.     case $name in
  15.         *.dpkg*)
  16.         continue;
  17.         ;;
  18.     esac
  19.     enabled=""
  20.     for f in $(ls /etc/rc?.d/[KS][0-9][0-9]$name 2> /dev/null) ; do
  21.         if [ -e $f ] ; then
  22.         if [ ! -f /var/lib/update-rc.d/$name ] ; then
  23.             missing="$missing $script"
  24.         else
  25.             present="$present $name"
  26.         fi
  27.         break;
  28.         fi
  29.     done
  30.     done
  31.  
  32.     if [ "$missing" ] ; then
  33.     # Not using debconf, as might not be available when the
  34.     # package is removed.
  35.     cat <<EOF
  36.  
  37. Unable to revert to legacy boot ordering and remove sysv-rc.  Missing
  38. update-rc.d information for the following packages:
  39.  
  40. EOF
  41.     # Map from script to packages
  42.     for pkg in $(dpkg -S $missing | cut -d: -f1 | sort -u) ; do
  43.         if dpkg -l $pkg | grep -q ^ii ; then
  44.         echo "  $pkg"
  45.         reconf="$reconf $pkg"
  46.         else
  47.         echo "  $pkg (removed but not purged)"
  48.         fi
  49.     done
  50.     cat <<EOF
  51.  
  52. This is due to earlier issues with sysv-rc and insserv.  To work
  53. around this issue, the packages listed need to register the
  54. update-rc.d call again, for example using
  55.  
  56.   dpkg-reconfigure $reconf
  57.  
  58. before trying again to migrate to legacy boot ordering.  The removed
  59. packages might need to be purged.  For some packages, purging and
  60. reinstalling might be needed to record the update-rc.d call.
  61.  
  62. Aborting package removal until this is done, to avoid leaving the boot
  63. system in a non-functioning state.  The insserv package needs to be
  64. installed to be able to reconfigure the packages.
  65.  
  66. EOF
  67.     return 1
  68.     fi
  69.  
  70.     # Enable legacy boot ordering, remove all start and stop symlinks,
  71.     # and register all scripts again.
  72.     echo "warning: reverting to legacy boot ordering"
  73.     touch /etc/init.d/.legacy-bootordering
  74.     for script in $present ; do
  75.     rm /etc/rc?.d/[KS][0-9][0-9]$script
  76.     sh /var/lib/update-rc.d/$script > /dev/null
  77.     done
  78.  
  79.     # Remove the recorded update-rc.d calls we just processed
  80.     rm -f /var/lib/update-rc.d/*
  81.  
  82.     return 0
  83. }
  84.  
  85. case "$1" in
  86.     remove)
  87.             # Refuse to be uninstalled unless all the needed
  88.             # update-rc.d calls are recorded already.
  89.         if [ ! -f /etc/init.d/.legacy-bootordering ] ; then
  90.         revert_to_legacy_ordering
  91.         exit $?
  92.         fi
  93.         ;;
  94.     *) : ;;
  95. esac
  96.  
  97. exit 0
  98.